﻿Imports System.Data.SqlClient

Public Class FormTypeeditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Cmd.Parameters("@TypeName") = Me.txtTypeName.Text
        Cmd.Parameters("@TypeId") = Me.txtTypeId.Text

        If Me.txtTypeId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Type VALUES(@TypeName,1);")
        Else
            Cmd.Parameters("@TypeId") = txtTypeId.Text
            Cmd.ExecuteNonQuery("UPDATE Type SET TypeName=@TypeName  WHERE TypeId=@TypeId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

End Class